//
//  NetBreakRuls.m
//  carcareIOS
//
//  Created by wr on 15/7/17.
//  Copyright (c) 2015年 baozun. All rights reserved.
//

#import "NetViolations.h"
#import "AIUserInfo.h"
#import "NetEngineServer.h"


@implementation NetViolations

+(void)vioCarListSuccess:(void (^)(NSArray<VioCarModel *> *))success fail:(void (^)())fail{
    [[[__SELF request:@"/violationNew/getVioCarList" withParams:nil type:REQUEST_GET] requestWithLoad:RequestLoadShowLoading] requestSuccess:^(id JSON) {
        NSArray *cars = JSON[@"data"];
        NSMutableArray *models = [NSMutableArray arrayWithCapacity:cars.count];
        [cars enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            VioCarModel *model = [[VioCarModel alloc] initWithDic:obj];
            [models addObject:model];
        }];
        if (success) success(models);
    } failure:^(id JSON) {
        if (fail) {
            fail();
        }
    }];
}

+(void)vioCarWithCarID:(NSInteger)carID unDel:(NSInteger)unDel success:(void (^)(VioCarModel *))success fail:(void (^)())fail{
    [[__SELF request:@"/violationNew/getVioCar" withParams:@{@"unDel" : @(unDel), @"carid" : @(carID)} type:REQUEST_GET] requestSuccess:^(id JSON) {
        if (success) success([[VioCarModel alloc] initWithDic:JSON[@"data"]]);
    } failure:^(id JSON) {
        if (fail) fail();
    }];
}

+(NetViolations *)violationCityList
{
    return [__SELF request:@"/Violation/eclicksCityList" withParams:nil type:REQUEST_POST];
}

+(NetViolations *)violationPayLinkWithCarInfo:(NSDictionary *)dataDic{
    return [__SELF request:@"/Violation/cxPayLink" withParams:dataDic type:REQUEST_POST];
}
-(NSDictionary *)requestCommonParams{
//    return @{@"userid":@(58064),@"session":@"64510d0f53a4465d9099ced1829eb18f"};
    if (![USERINFO.session isNotNil]) {
        return nil;
    }
    return @{@"userid":@(USERINFO.userID),@"session":USERINFO.session};
}

@end
